class Tea{
    constructor(id,teaname,teatype,teaimg,teaprice,teadescribe){
        this.id=id;
        this.teaname=teaname;
        this.teatype=teatype;
        this.teaimg=teaimg;
        this.teaprice=teaprice;
        this.teadescribe=teadescribe;   
    }
}

Mock.mock("/js/teaAdd","post",function(obj){
    let teaobj=JSON.parse(obj.body);
    let teaString=localStorage.Tea;
    if(teaString=="" || teaString==undefined || teaString==[] || teaString==null){
        let tea=new Tea(1,teaobj.teaname,teaobj.teatype,teaobj.teaimg,teaobj.teaprice,teaobj.teadescribe);
        let teaArr=[tea];
        localStorage.Tea=JSON.stringify(teaArr);
        return true;
    }else{
        let teaObjArr=JSON.parse(teaString);
        let bool=false;
        for(let i=0;i<teaObjArr.length;i++){
            if(teaObjArr[i].teaname==teaobj.teaname){
                bool=true;
                break;
            }
        }
        if(bool){
            return false;
        }else{;
            let tea=new Tea(getNewId(teaObjArr),teaobj.teaname,teaobj.teatype,teaobj.teaimg,teaobj.teaprice,teaobj.teadescribe);
            teaObjArr.push(tea);
            localStorage.Tea=JSON.stringify(teaObjArr);
            return true;
        }
    }  
})